Release 10.1A: OpenEdge Development:
ADM and SmartObjects
{get} and {set} pseudo-syntax for object properties
Progress supplies a
{get}and{set}pseudo-syntax in the ADM that can be used to access property values. It is implemented using Progress include files namedgetandset, located in theguiandttydirectories. This pseudo-syntax makes accessing property values as simple as possible, and it provides transparency to whether a property can be retrieved or set directly, or must be accessed through itsgetandsetfunctions. (The normal.iextension is removed to make these references look as much like standard syntax as possible.)Get include file logic
The
getinclude files use the following logic:
The
getsyntax first checks to see whether the preprocessorxppropnameexists. If it does, thegetsyntax returns the value in theTARGET-PROCEDURE’s ADMProps temp-table intotarget-variable. If the optionalobject-handleis specified, thegetsyntax searches that procedure’s ADMProps temp-table instead of theTARGET-PROCEDURE.If there is no
xppropnamepreprocessor constant, thegetpropnamefunction is executed in theTARGET-PROCEDURE(or in theobject-handle, if specified).This syntax is appropriate as an optimization for super procedures. In your application code, you should invoke the real functions.
Set include file logic
The
setinclude files operate similarly, as follows:
If
xppropnameis defined, that entry in theTARGET-PROCEDURE’s or theobject-handle’s ADMProps temp-table is set tovalue. Ifxppropnameis not defined, thesetpropnamefunction is executed and passed thevalue(in its native data type) as an input parameter. The function returnsTRUEorFALSE, depending on whether the operation was successful.The following example illustrates interpreting the
{get}logic:
How this translates depends on whether DataColumns has an xp preprocessor defined for it. If it does, the statement translates into the actual 4GL code:
This retrieves the handle of the ADMProps temp-table buffer for the
TARGET-PROCEDURE(stored in the procedure’sADM-DATAattribute) and then retrieves the field value using the dynamicBUFFER-FIELDattribute.If the preprocessor is not defined for DataColumns, the statement translates to the following:
The
ghPropvariable is defined insmart.ifor use by these include files. The buffer handle of the ADMProps property temp-table record is stored in theADM-DATAprocedure property of each SmartObject, so it can be located by these include files. These include files resolve during compilation to a single executable Progress statement, making them extremely fast.Using the get and set include files in other Progress code
You can use the
getandsetinclude files from any Progress code. When you use them either from a SmartObject of a given type or one of its super procedures, the syntax locates and uses the basic properties in the ADMProps property temp-table. If you use the syntax in other Progress application code (for example, in an object of a different type that does not share that property), it will not have a value for the preprocessor index and so will always use thegetandsetproperty functions.The
getandsetinclude files are not actual 4GL syntax and represent a fairly small optimization, so you should restrict their use to super procedures and use the standardgetandsetfunction invocations in other Progress application code. Further, any non-Progress code that uses the Open 4GL interfaces will be able to access the property only by invoking the appropriategetorsetfunctions directly. For this reason, you should always definegetpropnameandsetpropnamefunctions for each basic property intended to be read and written from outside the object’s class. These property functions can simply access the ADMProps value directly.Special properties
In some cases, it is desirable to store a property value in the ADMProps temp-table, to allow direct access to it from its super procedure and elsewhere, but also to have an action of some type take place when the value is set. For example, the
QueryPositionproperty holds information about the cursor position of a query (FirstRecord,LastRecord, and so on). Whenever its value is set, a message must be alsoPUBLISHed so other objects can react. In cases of this type, you should not define anxppropertynamepreprocessor constant, so thegetandsetfunctions that have the additional behavior will run instead of getting and setting the value directly in the ADMProps temp-table.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |